package com.jzhao.jpre.model;

import java.util.List;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.dao.DataAccessException;

import com.jzhao.jpre.base.Assembler;
import com.jzhao.jpre.base.StringPublicDeal;
import com.jzhao.jpre.model.dao.SysParamDao;

public class TestSysParam {
	public static void main(String[] args) {
		Assembler.start();

		SysParamDao sysParamDao = (SysParamDao) Assembler
				.getInstance("sysParamDao");
		StringPublicDeal cc = (StringPublicDeal) Assembler
				.getInstance("stringPublicDeal");

		SysParam sysParam = new SysParam();
		try {
			sysParam = sysParamDao.selectByParamName("AcctDate");
			System.out.println("ParamName = " + sysParam.getParamName());
			System.out.println("ParamType = " + sysParam.getParamType());
			System.out.println("ParamValue = " + sysParam.getParamValue());
			System.out.println("Memo = " + cc.convToGB2312(sysParam.getMemo()));
		} catch (DataAccessException dae) {
			System.out.println("ParamName doesn't exist!");
		}
		try {
			List sysPam = sysParamDao.select();
			for (int i = 0; i < sysPam.size(); i++) {
				System.out.println("ParamName = " + sysParam.getParamName());
				System.out.println("ParamType = " + sysParam.getParamType());
				System.out.println("ParamValue = " + sysParam.getParamValue());
				System.out.println("Memo = "
						+ cc.convToGB2312(sysParam.getMemo()));
			}
		} catch (DataAccessException dae) {
			System.out.println("ParamName doesn't exist!");
		}

		try {
			sysParamDao.updateSysParam("SysStat", "0");
		} catch (DataAccessException dae) {
			System.out.println("Update Failed!");
		}
	}
}
